package com.gitee.wsl.platform


//val isRunningInBrowser: Boolean by lazy { js("typeof window !== 'undefined'") }
//
//internal fun hasNodeApi(): Boolean = js(
//    """
//(typeof process !== 'undefined'
//&& process.versions != null
//&& process.versions.node != null) ||
//(typeof window !== 'undefined'
//&& typeof window.process !== 'undefined'
//&& window.process.versions != null
//&& window.process.versions.node != null)
//"""
//) as Boolean
//
//internal fun getJsRuntime() = if(hasNodeApi()) JsRuntime.Node else JsRuntime.Browser
//
//val os = if (isRunningInBrowser) null else js("require('os')")
//
//fun getEnvironmentVariables(): Map<String, String> =
//    if (isRunningInBrowser) {
//        // browsers are sandboxed, they have no access to system's environment variables
//        emptyMap()
//    } else {
//        val isProcessEnvDefined = js("""typeof process !== 'undefined' && process.env !== 'undefined'""")
//
//        if (isProcessEnvDefined != null) {
//            // don't know how to map dynamic returned from js("""typeof process !== 'undefined' && process.env""") to a Map<String, String>, so returning 'serialized' Map from JS directly
//            // js() does not support ES6, so we cannot use arrow functions (like '.map(([key, value]) => ...')
//            val envVarString: String = js("""Object.entries(process.env).map(function(entry) { return entry[0] + "=" + entry[1] }).join('\n')""")
//            val environmentVariables = envVarString.split('\n').map { it.split('=').let { it.first() to it[1] }}.toMap()
//
//            environmentVariables
//        } else {
//            emptyMap()
//        }
//    }

/** The platform this program runs on. */
//public actual val Current: Platform by lazy {
//    runCatching { kotlinx.browser.window }.fold({ Browser }, { NodeJS })
//}

